<template>
  <div>
    <Head/>
    <left/>
    <div style="position: absolute;top: 60px;left: 200px">
      <ul>
        <li v-for="(i,j) in task['params']" :key="i.id">
          {{ j }}-----:{{ i }}
        </li>
      </ul>
      {{ form.decision }}
      <van-radio-group v-model="form.decision" direction="horizontal">
        <van-radio name="1">同意</van-radio>
        <van-radio name="2">不同意</van-radio>
      </van-radio-group>
      <van-field label="审批意见" v-model="form.content"></van-field>
      <van-button round @click="add">提交</van-button>
    </div>
  </div>
</template>

<script>
import head from "@/components/head";
import left from "@/components/left";
import axios from "axios";

export default {
  components: {
    "Head": head,
    "left": left
  },
  name: "taskinfo",
  data() {
    return {
      task: {},
      id: this.$route.query.id,

      form: {'userid': localStorage.getItem('userid'), 'decision': '', 'content': '', 'taskid': this.$route.query.id}
    }
  },
  methods: {
    gettaskinfo() {
      axios({'url': '/work/taskinfo?id=' + this.id, 'method': 'get'}).then(res => {
        this.task = res.data.list
      })
    },
    add() {
      axios({'url': '/work/taskinfo', 'method': 'post', data: this.form})
          .then(res => {
            if (res.data.code == 200) {
              alert('提交成功')
            }
          })
    }
  },
  mounted() {
    this.gettaskinfo()
  }
}
</script>

<style scoped>

</style>